package com.rocpenghua.design.proxy.jdk;

/**
 * @author pengp
 * @date 2022年07月21日 15:59
 */
public class App {
    public static void main(String[] args) {
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles","true" );
        /**
         * 目标对象
         */
        UserDao target = new UserDao();
        //class com.rocpenghua.design.proxy.jdk.UserDao
        System.out.println(target.getClass());

        /**
         * 创建代理对象
         */
        IUserDao proxy = (IUserDao) new ProxyFactory(target).getProxyInstance();
        //class com.sun.proxy.$Proxy0
        System.out.println(proxy.getClass());

        proxy.save();
        System.out.println("----------------------1----------------------");
        proxy.delete();
        System.out.println("----------------------2----------------------");
        proxy.saveAndDelete();
    }
}
